home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
HyperLib 1997 Winter - Disc 1
/
HYPERLIB-1997-Winter-CD1.ISO.7z
/
HYPERLIB-1997-Winter-CD1.ISO
/
オンラインウェア
/
BUS
/
TMCM Software and Labs.sit
/
Software for TMCM 7_95
/
Files for Lab 11
/
Koch Curves
next >
Wrap
Text File
|
1993-10-31
|
2KB
|
90 lines
SUB Koch(dist,complexity)
{ Makes the Turtle move forward a distance of
dist, following a Koch curve of the given
complexity. }
IF complexity <= 1 THEN
forward(dist)
ELSE
koch(dist/3, complexity - 1)
turn(60)
koch(dist/3, complexity - 1)
turn(-120)
koch(dist/3, complexity - 1)
turn(60)
koch(dist/3, complexity - 1)
END IF
END SUB
SUB TestKoch
{ This subroutine can be called to draw sample Koch curves;
the user is asked to specify the complexity and a
Koch curve of that complexity is drawn stretch across most
of the screen. }
DECLARE complexity
penUp
MoveTo(-9,0)
penDown
face(0)
clear
AskUser("What level of complexity do you want (0 to 7)?", complexity)
complexity := trunc(complexity) { Make sure value is OK }
IF complexity < 0 THEN
complexity := 0
TellUser("Using complexity = 0.")
END IF
IF complexity > 7 THEN
complexity := 7
TellUser("Using complexity = 7.")
END IF
Koch(18,complexity)
END SUB
SUB Snowflake
{ This is similar to TestKoch, except that it draws
a "snowflake" curve consisting of three Koch curves
laid out in a triangle. }
DECLARE complexity
penUp
MoveTo(-6,4)
penDown
face(0)
clear
AskUser("What level of complexity do you want (0 to 7)?", complexity)
complexity := trunc(complexity) { Make sure value is OK }
IF complexity < 0 THEN
complexity := 0
TellUser("Using complexity = 0.")
END IF
IF complexity > 7 THEN
complexity := 7
TellUser("Using complexity = 7.")
END IF
Koch(12,complexity)
turn(-120)
Koch(12,complexity)
turn(-120)
Koch(12,complexity)
END SUB